package com.canaan.business.controller.pc.storehouse;

import java.util.List;

import com.canaan.business.domain.vo.StockCheckDiffVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.enums.BusinessType;
import javax.annotation.Resource;
import com.canaan.business.domain.storehouse.StockCheckDiff;
import com.canaan.business.service.storehouse.IStockCheckDiffService;
import com.canaan.common.utils.poi.ExcelUtil;
import com.canaan.common.core.page.TableDataInfo;

/**
 * 库存盘点差异Controller
 *
 * @author ruoyi
 * @date 2023-02-14
 */
@Api(tags = "库存盘点差异")
@RestController
@RequestMapping("/storehouse/checkDiff")
public class StockCheckDiffController extends BaseController {
    @Resource
    private IStockCheckDiffService stockCheckDiffService;

    /**
     * 查询库存盘点差异列表
     */
    @ApiOperation(value = "查询库存盘点差异列表")
    @GetMapping("/list")
    public TableDataInfo list(StockCheckDiff stockCheckDiff) {
        startPage();
        List<StockCheckDiff> list = stockCheckDiffService.selectStockCheckDiffList(stockCheckDiff);
        return getDataTable(list);
    }




    /**
     * 导出库存盘点差异列表
     */
    @ApiOperation(value = "导出库存盘点差异列表")
    @Log(title = "库存盘点差异", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockCheckDiff stockCheckDiff) {
        List<StockCheckDiff> list = stockCheckDiffService.selectStockCheckDiffList(stockCheckDiff);
        ExcelUtil<StockCheckDiff> util = new ExcelUtil<StockCheckDiff>(StockCheckDiff.class);
        util.exportExcel(response, list, "库存盘点差异数据");
    }

    /**
     * 获取库存盘点差异详细信息
     */
    @ApiOperation(value = "获取库存盘点差异详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(stockCheckDiffService.selectStockCheckDiffById(id));
    }

    /**
     * 新增库存盘点差异
     */
    @ApiOperation(value = "新增库存盘点差异")
    @Log(title = "库存盘点差异", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockCheckDiff stockCheckDiff) {
        return toAjax(stockCheckDiffService.insertStockCheckDiff(stockCheckDiff));
    }

    /**
     * 修改库存盘点差异
     */
    @ApiOperation(value = "修改库存盘点差异")
    @Log(title = "库存盘点差异", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockCheckDiff stockCheckDiff) {
        return toAjax(stockCheckDiffService.updateStockCheckDiff(stockCheckDiff));
    }

    /**
     * 删除库存盘点差异
     */
    @ApiOperation(value = "删除库存盘点差异")
    @Log(title = "库存盘点差异", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(stockCheckDiffService.deleteStockCheckDiffByIds(ids));
    }

    /**
     * 新增库存盘点差异
     */
    @ApiOperation(value = "盘点任务查询")
    @GetMapping("/queryCheckTaskDetails")
    public AjaxResult queryCheckTaskDetails() {
        return stockCheckDiffService.queryCheckTaskDetails();
    }

    /**
     * 新增库存盘点差异
     */
    @ApiOperation(value = "查询已完成盘点任务")
    @GetMapping("/queryCheckTaskCompletedDetails")
    public AjaxResult queryCheckTaskCompletedDetails() {
        return stockCheckDiffService.queryCheckTaskCompletedDetails();
    }

    /**
     * 新增库存盘点差异
     */
    @ApiOperation(value = "查询盘点")
    @PostMapping("/queryCheckDetailInfos")
    public AjaxResult queryCheckDetailInfos(@RequestBody StockCheckDiffVo stockCheckDiff) {
        return stockCheckDiffService.queryCheckDetailInfos(stockCheckDiff);
    }

    /**
     * 修改库存盘点差异
     */
    @ApiOperation(value = "盘点完成")
    @Log(title = "盘点完成", businessType = BusinessType.UPDATE)
    @PostMapping("/checkComplete")
    public AjaxResult checkComplete(@RequestBody List<StockCheckDiff> stockCheckDiffs) {
        return stockCheckDiffService.checkComplete(stockCheckDiffs);
    }


}
